import axios from 'axios'

const instance = axios.create({
    baseURL: "http://gz.wolfcode.cn/cms",
    timeout: 5000,
})

instance.interceptors.request.use(config => {
    if (config.url === './sendSNS' || config.url === '/phoneRegin' || config.url === '/wechatUsers/PCLogin') {
        config.headers['Content.Type'] = 'application/x-www-form-urlencoded'
    }
    const token = localStorage.getItem('x-auth-token')
    if (token) {
        config.headers['x-auth-token'] = token
    }

    return config
})

instance.interceptors.response.use(res => {
    return res.data
})

export default instance